
<f:view>
    <h:form>
        <rich:toolBar itemSeparator="line" >
            <h:commandLink value="New thread" target="message" action="#{ForumsRequest.nTopic}" >
                <f:setPropertyActionListener target="#{ForumsSession.currentThread}" value="#{null}" />
                <f:setPropertyActionListener target="#{ForumsSession.created}" value="#{false}" />
            </h:commandLink>
            <h:commandLink value="Last 24h" rendered="#{!ForumsSession.last}" target="menu">
                <f:setPropertyActionListener target="#{ForumsSession.last}" value="#{true}" />
            </h:commandLink>
            <h:commandLink value="All" rendered="#{ForumsSession.last}" target="menu">
                <f:setPropertyActionListener target="#{ForumsSession.last}" value="#{false}" />
            </h:commandLink>
            <h:commandLink value="Search" target="message" action="search" >
                <f:setPropertyActionListener target="#{ForumsSession.handleSearchString}" value="#{null}" />
                <f:setPropertyActionListener target="#{ForumsSession.searchString}" value="#{null}" />
            </h:commandLink>
        </rich:toolBar>
        <div align="right" >
            <rich:panel style="border:0px">
                <h:commandLink value="Refresh" action="saa" />
            </rich:panel>
        </div>
        <rich:panel id="tree" style="width: 100%; border:0px">
            <rich:panel style="width: 100%; border:0px">
                <h:outputText value="No threads were created." rendered="#{empty ForumsSession.topics}" />
                <rich:tree id="threads" switchType="client" style="width: 470px" icon="/images/text.png" iconLeaf="/images/text.png" adviseNodeOpened="#{ForumsRequest.adviseNodeOpened}" >
                    <rich:treeNodesAdaptor  nodes="#{ForumsSession.topics}" var="topic" >
                        <rich:treeNode>
                            <h:commandLink value="#{topic.subject}" target="message" action="topic">
                                <f:setPropertyActionListener target="#{ForumsSession.currentThread}" value="#{topic}" />
                            </h:commandLink>
                        </rich:treeNode>
                        <rich:recursiveTreeNodesAdaptor roots="#{topic.messages}"  var="message" nodes="#{message.messages}">
                            <rich:treeNode>
                                <a4j:htmlCommandLink rendered="#{message.message!=null}" value="Re: " target="message" action="message">
                                    <f:setPropertyActionListener target="#{ForumsSession.currentMessage}" value="#{message}" />
                                </a4j:htmlCommandLink>
                                <a4j:htmlCommandLink value="#{message.subject}" target="message" action="message">
                                    <f:setPropertyActionListener target="#{ForumsSession.currentMessage}" value="#{message}" />
                                </a4j:htmlCommandLink>
                            </rich:treeNode>
                        </rich:recursiveTreeNodesAdaptor>
                    </rich:treeNodesAdaptor>
                </rich:tree>
            </rich:panel>
            <br>
            <h:panelGroup rendered="#{ForumsSession.paginate}" >
                <a4j:commandLink value="<" reRender="tree" rendered="#{ForumsSession.treeForum>0}">
                    <f:setPropertyActionListener target="#{ForumsSession.treeForum}" value="#{ForumsSession.treeForum-1}" />
                </a4j:commandLink>
                <c:forEach var="page" items="#{ForumsSession.pages}">
                    <a4j:commandLink value="#{page}" reRender="tree" >
                        <f:setPropertyActionListener target="#{ForumsSession.treeForum}" value="#{page-1}" />
                    </a4j:commandLink>
                </c:forEach>
                <a4j:commandLink value=">" reRender="tree" rendered="#{ForumsSession.treeForum<topicsBean.size-1}">
                    <f:setPropertyActionListener target="#{ForumsSession.treeForum}" value="#{ForumsSession.treeForum+1}" />
                </a4j:commandLink>
            </h:panelGroup>
        </rich:panel>
    </h:form>
    </f:view>
    
    